# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gnupg
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.4.16
pkgrel=1
pkgdesc="GNU Privacy Guard - a PGP replacement tool (mingw-w64)"
arch=('any')
groups=("${MINGW_PACKAGE_PREFIX}")
depends=("${MINGW_PACKAGE_PREFIX}-curl"
        "${MINGW_PACKAGE_PREFIX}-bzip2"
        "${MINGW_PACKAGE_PREFIX}-zlib"
        "${MINGW_PACKAGE_PREFIX}-libksba"
        "${MINGW_PACKAGE_PREFIX}-libgcrypt"
        "${MINGW_PACKAGE_PREFIX}-libassuan" 
        "${MINGW_PACKAGE_PREFIX}-libgnurx"
        "${MINGW_PACKAGE_PREFIX}-w32pth")
makedepends=("texinfo" "${MINGW_PACKAGE_PREFIX}-gcc")
license=('GPL')
url="http://www.gnupg.org/"
source=(ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-$pkgver.tar.bz2{,.sig}
        gnupg-1.4.15-libiconv-dll.patch)
sha1sums=('0bf5e475f3eb6f33d5474d017fe5bf66070e43f4'
          'SKIP'
          '2ea46a1c24a30016e21b9f16e324798ec2b54d98')

prepare() {
  cd "${srcdir}"/gnupg-${pkgver}
  patch -p1 -i ${srcdir}/gnupg-1.4.15-libiconv-dll.patch
  
  #./autogen.sh
 # libtoolize --copy --force
 # aclocal -I m4 -I gl/m4
 # automake --add-missing
 # autoconf
}

build() {
  mkdir -p "${srcdir}/gnupg-${pkgver}-build-${CARCH}"
  cd "${srcdir}/gnupg-${pkgver}-build-${CARCH}"
  "${srcdir}"/gnupg-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --libexecdir=${MINGW_PREFIX}/lib
  make
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}-build-${CARCH}"
  make check
}

package() {
  cd "${srcdir}/gnupg-${pkgver}-build-${CARCH}"
  make DESTDIR=${pkgdir} install
  # move conflicting files
  #mv ${pkgdir}${MINGW_PREFIX}/share/gnupg{,2}
}
